package com.itheima.pattern.observer;

import java.util.ArrayList;
import java.util.List;

public class SubscriptionSubject implements Subject{
    private List<Observer> weixinUserlist=new ArrayList<>();

    /**
     * 添加观察者对象
     * @param observer
     */
    @Override
    public void attach(Observer observer) {
        weixinUserlist.add(observer);
    }


    /**
     * 删除观察者对象
     * @param observer
     */
    @Override
    public void detach(Observer observer) {
        weixinUserlist.remove(observer);
    }

    @Override
    public void notify(String message) {
        for(Observer o:weixinUserlist){
            o.update(message);
        }
    }
}
